package thread;

import java.util.Scanner;

/**
 * sleep阻塞
 */
public class SleepDemo {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入一个数字：");

        int i=scan.nextInt();
        System.out.println("倒计时：");

        while (true){
            try {
                System.out.println("剩余时间："+i+"s");
                if(i <=0){
                    break;
                }
                i-=1;
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("倒计时结束！");














//        System.out.println("程序开始了...");
//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        System.out.println("程序结束了！");
//
//        System.out.println("程序开始了！");
//        try {
//            Thread .sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        System.out.println("程序结束了！");
    }
}
